package com.tuFat.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tuFat.model.Sign;
import com.tuFat.service.SignService;

import cn.hutool.core.util.ObjectUtil;
import net.sf.json.JSONObject;

@Controller
@RequestMapping("/sign/")
public class SignController {
	
	@Resource
	private SignService signService;
	
	/**
     * 签到
     */
    @ResponseBody
    @RequestMapping("signInfo")
    public String signInfo(Sign sign) {
    	JSONObject jsonObject = new JSONObject();
        if (ObjectUtil.isNull(sign.getName()) || ObjectUtil.isNull(sign.getMobile())) {
        	jsonObject.put("RESULT_CODE", "20001");
        	jsonObject.put("RESULT_MSG", "姓名手机号必填");
        	return jsonObject.toString();
        }
        signService.insert(sign);
        jsonObject.put("RESULT_CODE", "20000");
    	jsonObject.put("RESULT_MSG", "签到成功");
		return jsonObject.toString();
       
    }

}
